/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package podologia.beansDB;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Hernan
 */
@Entity
@Table(name = "proveedor")
@NamedQueries({@NamedQuery(name = "Proveedor.findAll", query = "SELECT p FROM Proveedor p"), @NamedQuery(name = "Proveedor.findByIdProveedor", query = "SELECT p FROM Proveedor p WHERE p.idProveedor = :idProveedor"), @NamedQuery(name = "Proveedor.findByRazonSocial", query = "SELECT p FROM Proveedor p WHERE p.razonSocial = :razonSocial"), @NamedQuery(name = "Proveedor.findByCuit", query = "SELECT p FROM Proveedor p WHERE p.cuit = :cuit"), @NamedQuery(name = "Proveedor.findByIngresosBrutos", query = "SELECT p FROM Proveedor p WHERE p.ingresosBrutos = :ingresosBrutos"), @NamedQuery(name = "Proveedor.findByTelEmpresa", query = "SELECT p FROM Proveedor p WHERE p.telEmpresa = :telEmpresa"), @NamedQuery(name = "Proveedor.findByFax", query = "SELECT p FROM Proveedor p WHERE p.fax = :fax"), @NamedQuery(name = "Proveedor.findByEmail", query = "SELECT p FROM Proveedor p WHERE p.email = :email"), @NamedQuery(name = "Proveedor.findByNombreVendedor", query = "SELECT p FROM Proveedor p WHERE p.nombreVendedor = :nombreVendedor"), @NamedQuery(name = "Proveedor.findByApellidoVendedor", query = "SELECT p FROM Proveedor p WHERE p.apellidoVendedor = :apellidoVendedor"), @NamedQuery(name = "Proveedor.findByTelVendedor", query = "SELECT p FROM Proveedor p WHERE p.telVendedor = :telVendedor"), @NamedQuery(name = "Proveedor.findByMailVendedor", query = "SELECT p FROM Proveedor p WHERE p.mailVendedor = :mailVendedor")})
public class Proveedor implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "idProveedor")
    private Integer idProveedor;
    @Column(name = "razonSocial")
    private String razonSocial;
    @Column(name = "cuit")
    private String cuit;
    @Column(name = "ingresosBrutos")
    private String ingresosBrutos;
    @Column(name = "telEmpresa")
    private String telEmpresa;
    @Column(name = "fax")
    private String fax;
    @Column(name = "email")
    private String email;
    @Column(name = "nombreVendedor")
    private String nombreVendedor;
    @Column(name = "apellidoVendedor")
    private String apellidoVendedor;
    @Column(name = "telVendedor")
    private String telVendedor;
    @Column(name = "mailVendedor")
    private String mailVendedor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idProveedor")
    private Collection<Materialesxproveedor> materialesxproveedorCollection;
    @OneToMany(mappedBy = "idProveedor")
    private Collection<Pedido> pedidoCollection;
    @JoinColumn(name = "idDireccion", referencedColumnName = "idDireccion")
    @ManyToOne ( cascade=CascadeType.ALL)
    private Direccion idDireccion;

    public Proveedor() {
    }

    public Proveedor(Integer idProveedor) {
        this.idProveedor = idProveedor;
    }

    public Integer getIdProveedor() {
        return idProveedor;
    }

    public void setIdProveedor(Integer idProveedor) {
        Integer oldIdProveedor = this.idProveedor;
        this.idProveedor = idProveedor;
        changeSupport.firePropertyChange("idProveedor", oldIdProveedor, idProveedor);
    }

    public String getRazonSocial() {
        return razonSocial;
    }

    public void setRazonSocial(String razonSocial) {
        String oldRazonSocial = this.razonSocial;
        this.razonSocial = razonSocial;
        changeSupport.firePropertyChange("razonSocial", oldRazonSocial, razonSocial);
    }

    public String getCuit() {
        return cuit;
    }

    public void setCuit(String cuit) {
        String oldCuit = this.cuit;
        this.cuit = cuit;
        changeSupport.firePropertyChange("cuit", oldCuit, cuit);
    }

    public String getIngresosBrutos() {
        return ingresosBrutos;
    }

    public void setIngresosBrutos(String ingresosBrutos) {
        String oldIngresosBrutos = this.ingresosBrutos;
        this.ingresosBrutos = ingresosBrutos;
        changeSupport.firePropertyChange("ingresosBrutos", oldIngresosBrutos, ingresosBrutos);
    }

    public String getTelEmpresa() {
        return telEmpresa;
    }

    public void setTelEmpresa(String telEmpresa) {
        String oldTelEmpresa = this.telEmpresa;
        this.telEmpresa = telEmpresa;
        changeSupport.firePropertyChange("telEmpresa", oldTelEmpresa, telEmpresa);
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        String oldFax = this.fax;
        this.fax = fax;
        changeSupport.firePropertyChange("fax", oldFax, fax);
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        String oldEmail = this.email;
        this.email = email;
        changeSupport.firePropertyChange("email", oldEmail, email);
    }

    public String getNombreVendedor() {
        return nombreVendedor;
    }

    public void setNombreVendedor(String nombreVendedor) {
        String oldNombreVendedor = this.nombreVendedor;
        this.nombreVendedor = nombreVendedor;
        changeSupport.firePropertyChange("nombreVendedor", oldNombreVendedor, nombreVendedor);
    }

    public String getApellidoVendedor() {
        return apellidoVendedor;
    }

    public void setApellidoVendedor(String apellidoVendedor) {
        String oldApellidoVendedor = this.apellidoVendedor;
        this.apellidoVendedor = apellidoVendedor;
        changeSupport.firePropertyChange("apellidoVendedor", oldApellidoVendedor, apellidoVendedor);
    }

    public String getTelVendedor() {
        return telVendedor;
    }

    public void setTelVendedor(String telVendedor) {
        String oldTelVendedor = this.telVendedor;
        this.telVendedor = telVendedor;
        changeSupport.firePropertyChange("telVendedor", oldTelVendedor, telVendedor);
    }

    public String getMailVendedor() {
        return mailVendedor;
    }

    public void setMailVendedor(String mailVendedor) {
        String oldMailVendedor = this.mailVendedor;
        this.mailVendedor = mailVendedor;
        changeSupport.firePropertyChange("mailVendedor", oldMailVendedor, mailVendedor);
    }

    public Collection<Materialesxproveedor> getMaterialesxproveedorCollection() {
        return materialesxproveedorCollection;
    }

    public void setMaterialesxproveedorCollection(Collection<Materialesxproveedor> materialesxproveedorCollection) {
        this.materialesxproveedorCollection = materialesxproveedorCollection;
    }

    public Collection<Pedido> getPedidoCollection() {
        return pedidoCollection;
    }

    public void setPedidoCollection(Collection<Pedido> pedidoCollection) {
        this.pedidoCollection = pedidoCollection;
    }

    public Direccion getIdDireccion() {
        return idDireccion;
    }

    public void setIdDireccion(Direccion idDireccion) {
        Direccion oldIdDireccion = this.idDireccion;
        this.idDireccion = idDireccion;
        changeSupport.firePropertyChange("idDireccion", oldIdDireccion, idDireccion);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idProveedor != null ? idProveedor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Proveedor)) {
            return false;
        }
        Proveedor other = (Proveedor) object;
        if ((this.idProveedor == null && other.idProveedor != null) || (this.idProveedor != null && !this.idProveedor.equals(other.idProveedor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "javaapplication2.Proveedor[idProveedor=" + idProveedor + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

     public String getNombreCompleto(){
        return razonSocial;

    }

}
